#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=1005,mod=1e9+7;
int n,k;
char s[Maxn];

char a[Maxn],b[Maxn];

int f[1005][1005][2],g[1005][1005][2],C[1005][1005],pw[1005];

inline void init(int N){
	pw[0]=1;for(int i=1;i<=N;i++)pw[i]=(pw[i-1]+pw[i-1])%mod;
	for(int i=0;i<=N;i++)C[i][0]=1;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=i;j++)C[i][j]=(C[i][j-1]+C[i-1][j-1])%mod;
}

inline int calc(char*p){
	if(strlen(p+1)<n)return 0;
	int res=0;
	memset(f,0,sizeof f);memset(g,0,sizeof g);
	if(p[1]=='0')return 0;
	f[0][0][1]=pw[n-1]%mod;
	g[0][0][1]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=min(i-1,k);j++){
			if((s[i]=='L'&&(j%2==0))||(s[i]=='R'&&(j%2==1))){
				f[i][j][0]=(f[i][j][0]+f[i-1][j][0])%mod;
				g[i][j][0]=(g[i][j][0]+g[i-1][j][0])%mod;
				
				f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][0]+g[i-1][j][0]*pw[n-1-i])%mod;
				g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][0])%mod;
				
				if(p[i+1]=='1'){
					f[i][j][0]=(f[i][j][0]+f[i-1][j][1])%mod;
					g[i][j][0]=(g[i][j][0]+g[i-1][j][1])%mod;
					
					f[i][j+1][1]=(f[i][j+1][1]+f[i-1][j][1]+g[i-1][j][1]*pw[n-1-i])%mod;
					g[i][j+1][1]=(g[i][j+1][1]+g[i-1][j][1])%mod;
					
				}else{
					f[i][j][1]=(f[i][j][1]+f[i-1][j][1])%mod;
					g[i][j][1]=(g[i][j][1]+g[i-1][j][1])%mod;
				}
			}
			else{
				f[i][j][0]=(f[i][j][0]+f[i-1][j][0]+g[i-1][j][0]*pw[n-1-i])%mod;
				g[i][j][0]=(g[i][j][0]+g[i-1][j][0])%mod;
				
				
				f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][0])%mod;
				g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][0])%mod;
				
				
				if(p[i+1]=='1'){
					f[i][j][1]=(f[i][j][1]+f[i-1][j][1]+g[i-1][j][1]*pw[n-1-i])%mod;
					g[i][j][1]=(g[i][j][1]+g[i-1][j][1])%mod;
					
					
					f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][1])%mod;
					g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][1])%mod;
				}else{
					f[i][j+1][1]=(f[i][j+1][1]+f[i-1][j][1])%mod;
					g[i][j+1][1]=(g[i][j+1][1]+g[i-1][j][1])%mod;
				}
			}
		}
	}
	res=(f[n-1][k][0]+f[n-1][k][1])%mod;
	memset(f,0,sizeof f);memset(g,0,sizeof g);
	f[0][0][1]=pw[n-1]%mod;
	g[0][0][1]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=min(i-1,k);j++){
			if((s[i]=='R'&&(j%2==0))||(s[i]=='L'&&(j%2==1))){
				f[i][j][0]=(f[i][j][0]+f[i-1][j][0])%mod;
				g[i][j][0]=(g[i][j][0]+g[i-1][j][0])%mod;
				
				f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][0]+g[i-1][j][0]*pw[n-1-i])%mod;
				g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][0])%mod;
				
				if(p[i+1]=='1'){
					f[i][j][0]=(f[i][j][0]+f[i-1][j][1])%mod;
					g[i][j][0]=(g[i][j][0]+g[i-1][j][1])%mod;
					
					f[i][j+1][1]=(f[i][j+1][1]+f[i-1][j][1]+g[i-1][j][1]*pw[n-1-i])%mod;
					g[i][j+1][1]=(g[i][j+1][1]+g[i-1][j][1])%mod;
					
				}else{
					f[i][j][1]=(f[i][j][1]+f[i-1][j][1])%mod;
					g[i][j][1]=(g[i][j][1]+g[i-1][j][1])%mod;
				}
			}
			else{
				f[i][j][0]=(f[i][j][0]+f[i-1][j][0]+g[i-1][j][0]*pw[n-1-i])%mod;
				g[i][j][0]=(g[i][j][0]+g[i-1][j][0])%mod;
				
				
				f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][0])%mod;
				g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][0])%mod;
				
				
				if(p[i+1]=='1'){
					f[i][j][1]=(f[i][j][1]+f[i-1][j][1]+g[i-1][j][1]*pw[n-1-i])%mod;
					g[i][j][1]=(g[i][j][1]+g[i-1][j][1])%mod;
					
					
					f[i][j+1][0]=(f[i][j+1][0]+f[i-1][j][1])%mod;
					g[i][j+1][0]=(g[i][j+1][0]+g[i-1][j][1])%mod;
				}else{
					f[i][j+1][1]=(f[i][j+1][1]+f[i-1][j][1])%mod;
					g[i][j+1][1]=(g[i][j+1][1]+g[i-1][j][1])%mod;
				}
			}
		}
	}res=(res+f[n-1][k][0]+f[n-1][k][1])%mod;
	return res;
}

signed main(){
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	n=read();k=read();init(1000);
	if(n==1)puts("1"),exit(0);
	scanf("%s",s+1);
	scanf("%s",b+1);
	scanf("%s",a+1);
	int now=strlen(b+1);
	while(now&&b[now]=='0')b[now--]='1';
	b[now]='0';
//	printf("test: %s\n",b+1);
	
//	printf("fwew %d\n",calc(a));
//	printf("fewfwefw %d\n",calc(b));
	
	printf("%lld",(calc(a)-calc(b)+mod)%mod);
	return 0;
}
/*
1 0
1
1


3 0
LR
101
110


4 2
LRR
1010
1110

4 2
LRR
1110
1110


4 2
LRR
1101
1101

5 2
RLLR
10010
10111
*/
